import { useState } from 'react';
import { authService, LoginCredentials } from '../services/auth';

export const useLogin = () => {
  const [isLoading, setIsLoading] = useState(false);

  const login = async (credentials: LoginCredentials) => {
    try {
      setIsLoading(true);
      const response = await authService.login(credentials);
      authService.setToken(response.token);
      return response;
    } finally {
      setIsLoading(false);
    }
  };

  return {
    login,
    isLoading,
  };
}; 